/*
 * BBActionSetMode.java
 *
 * Created on March 15, 2008, 4:24 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package hextd.blackBox;

import hextd.util.Context;

/**
 *
 * @author hylke
 */
public class BBActionSetMode implements BBAction {
    
    private static final BlackBox.ActionType type = BlackBox.ActionType.SetMode;
    private int gameTime;
    private int row;
    private int col;
    private int m;
    private int v;
    
    /** Creates a new instance of BBActionSetMode */
    public BBActionSetMode(int gameTime, int row, int col, int m, int v) {
        this.gameTime = gameTime;
        this.row = row;
        this.col = col;
        this.m = m;
        this.v = v;
    }
    
    @Override
    public BlackBox.ActionType getType() {
        return BBActionSetMode.type;
    }
    
    @Override
    public int getGameTime() {
        return this.gameTime;
    }
    
    @Override
    public void execute(Context c) {
        //System.out.println("BBActionSetMode::execute: "+c.gameTime+" Setting mode "+this.m+" to "+this.v+".");
        if (!c.blackBoxCurrent.setMode(this.col, this.row, this.m, this.v)) {
            System.err.println("BBActionSetMode::execute: Sync error: Setting mode for tower failed!");
        }
    }
    
    @Override
    public String getString() {
        return ""+this.gameTime+" M "+this.row+" "+this.col+" "+this.m+" "+this.v+"\n";
    }
}
